<?
session_start();

if( empty($_SESSION['user_id']) ) {
	$to_url = "index.php";
	if( isset($back_to_url) ){
		$to_url = $back_to_url;
	}
	echo "<script> window.location = 'login.php?to_url=". $to_url ."'; </script>";
	exit;
}
?>